package com.sky.controller.admin;


import com.sky.dto.*;
import com.sky.result.Result;
import com.sky.service.IOrdersService;
import com.sky.vo.OrderPageVO;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author xieminghui
 * @since 2023-11-16
 */
@RestController
@RequestMapping("/admin/order")
public class OrdersController {
    @Resource
    private IOrdersService ordersService;
    /**
     * 1.统计所有状态订单
     * @author: XieMingHui
     * @date: 23/11/21 8:31:48
     * @param: []
     * @return: com.sky.result.Result<com.sky.vo.OrderStatisticsVO>
     **/
     @GetMapping("/statistics")
     public Result<OrderStatisticsVO> statisticsOrders(){
        return ordersService.statisticsOrders();
     }

    /**
     * 2.根据id查询订单详情
     *
     * @author: XieMingHui
     * @date: 23/11/21 8:32:05
     * @param: [订单id]
     * @return: com.sky.result.Result<java.lang.String>
     **/
    @GetMapping("/details/{id}")
    public Result<OrderVO> findOrderById(@PathVariable Long id) {
        return ordersService.findOrderById(id);
    }

    /**
     * 3.订单搜索
     *
     * @author: XieMingHui
     * @date: 23/11/21 8:32:05
     * @param: [请求字符串参数:页码,长度,状态,订单号,手机号,时间]
     * @return: com.sky.result.Result<java.lang.String>
     **/
    @GetMapping("/conditionSearch")
    public Result<OrderPageVO> findOrderPage(OrdersPageQueryDTO ordersPageQueryDTO) {
        return ordersService.findOrderPage(ordersPageQueryDTO);
    }

    /**
     * 4.取消订单
     *
     * @author: XieMingHui
     * @date: 23/11/21 8:32:05
     * @param: [OrdersCancelDTO]
     * @return: 操作成功
     **/
    @PutMapping("/cancel")
    public Result<String> cancelOrder(@RequestBody OrdersCancelDTO ordersCancelDTO) {
        return ordersService.cancelOrder(ordersCancelDTO);
    }

    /**
     * 5.拒单
     *
     * @author: XieMingHui
     * @date: 23/11/21 8:32:05
     * @param: [OrdersRejectionDTO]
     * @return: 操作成功
     **/
    @PutMapping("/rejection")
    public Result<String> rejectionOrder(@RequestBody OrdersRejectionDTO ordersRejectionDTO) {
        return ordersService.rejectionOrder(ordersRejectionDTO);
    }

    /**
     * 6. 确认接单
     *
     * @author: XieMingHui
     * @date: 23/11/21 8:32:05
     * @param: [OrdersConfirmDTO]
     * @return: 操作成功
     **/
    @PutMapping("/confirm")
    public Result<String> confirmOrder(@RequestBody OrdersConfirmDTO ordersConfirmDTO) {
        return ordersService.confirmOrder(ordersConfirmDTO);
    }

    /**
     * 7.派送订单
     *
     * @author: XieMingHui
     * @date: 23/11/21 8:32:05
     * @param: [订单id]
     * @return: 操作成功
     **/
    @PutMapping("/delivery/{id}")
    public Result<String> deliveryOrder(@PathVariable Long id) {
        return ordersService.deliveryOrder(id);
    }

    @PutMapping("/delivery/undefined")
    public Result<String> undefinedOrder(@RequestBody UndefinedOrderDTO undefinedOrderDTO) {
        return ordersService.undefinedOrder(undefinedOrderDTO);
    }

    /**
     * 8.完成订单
     *
     * @author: XieMingHui
     * @date: 23/11/21 8:32:05
     * @param: [订单id]
     * @return: 操作成功
     **/
    @PutMapping("/complete/{id}")
    public Result<String> completeOrder(@PathVariable Long id) {
        return ordersService.completeOrder(id);
    }
}
